﻿commons = commons || {};
//公共-复选框
commons.checkbox = function () {
    return {
        selected: function (gridId) {
            ///<summary>
            ///获取复选框选中
            ///</summary>
            var result = [];
            var checkedRows = $.easyui.getGrid(gridId).datagrid("getChecked");
            $.each(checkedRows, function (i, row) {
                result.push(row.Id);
            });
            if (result.length > 0)
                return result;
            return null;
        },

        all: function (gridId) {
            ///<summary>
            ///获取全部
            ///</summary>
            var ids = commons.checkbox.selected(gridId);
            if (ids)
                return ids;
            var selectedRow = $.easyui.getGrid(gridId).etreegrid("getSelected");
            if (!selectedRow) {
                return null;
            }
            return selectedRow.Id;
        }
    }
}();
